package com.fingard.dsp.bank.reqrespobj.single;

import java.util.HashMap;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.dsp.bank.reqrespobj.batpayrec.RetAtsBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batpayrec.RetAtsQryBatPayRec;
import com.fingard.dsp.bank.reqrespobj.single.detail.RetAtsSglDetail;
import com.fingard.xml.XmlTextWriter;

//普通单笔支付提交或查询返回ATS通用对象
public class RetAtsSingle extends RetAtsBase{

	public RetAtsSingle(ReqRespHeader p_header){
		retHeader = p_header;
		retXmlWriter = new XmlTextWriter();//用于输出返回ATS的XML报文
	}

	public void writeRetDetail(RetAtsSglDetail p_detail) throws  Exception{
		writeStart();//写返回ATS的统一头部信息
		retDetail = p_detail;
		
		p_detail.writeToXml(retXmlWriter,retHeader.bankCode,retHeader.transType);
		
		retXmlWriter.writeEndElement();
		writeEnd();//写结束
	}
	
	public void writeDetailByDate(RetAtsSglDetail p_detail) throws Exception{
		if(!hasWrittenRespCode){
			writeBatRespCode("0");
			writeBatRespInfo("查询成功");
		}
		p_detail.writeToXml(retXmlWriter,retHeader.bankCode,retHeader.transType);
	}
	
	public RetAtsSglDetail retDetail;
	public HashMap<String,String> getRetAtsHashMap(){
		return retDetail.writeToHash();
    }
	
	/**批量转单笔时，返回赋值批量响应对象*/
	public void fillToBatRetAts(RetAtsBatPayRec p_retAtsBat){
		p_retAtsBat.respCode = retDetail.respCode;
		p_retAtsBat.respInfo = retDetail.respInfo;
		p_retAtsBat.transState = retDetail.transState;
		p_retAtsBat.payInfoCode = retDetail.payInfoCode;
		p_retAtsBat.reqSeqID = retDetail.reqSeqID;
	}
	
	public void fillToBatRetAts(RetAtsQryBatPayRec p_retAtsBat){
		p_retAtsBat.respCode = retDetail.respCode;
		p_retAtsBat.respInfo = retDetail.respInfo;
		p_retAtsBat.transState = retDetail.transState;
		p_retAtsBat.payInfoCode = retDetail.payInfoCode;
		p_retAtsBat.reqSeqID = retDetail.reqSeqID;
	}
}
